package bio;

import java.io.IOException;
import java.net.InetSocketAddress;
import java.net.Socket;
import java.util.concurrent.CountDownLatch;
import java.util.concurrent.atomic.AtomicInteger;

/**
 * @author tee
 * @date 2025/9/30
 */
public class BioClient {
    public static void main(String[] args) throws InterruptedException {
        AtomicInteger atomicInteger = new AtomicInteger(0);
        // 连接server
        CountDownLatch countDownLatch = new CountDownLatch(1);
        for (int i = 0; i < 10; i++) {
            new Thread(() -> {
                try {
                    Socket socket = new Socket();
                    countDownLatch.await();
                    socket.connect(new InetSocketAddress(9090));
                } catch (IOException | InterruptedException e) {
                    throw new RuntimeException(e);
                }
                System.out.println("连接完成" + atomicInteger.getAndIncrement());
            }).start();
        }
        countDownLatch.countDown();
        Thread.sleep(100000);
    }
}
